library(osmdata)
library(opentripplanner)
library(tidyverse)
library(sf)
library(ggthemes)
library(ggspatial)
library(dplyr)
library(plyr)
library(wesanderson)
For this assignment, I want to look at walksheds and bikesheds for museums in NYC. There are 130 museums in the KML list from NYC Open Data. To stay consistent with this assignment’s instructions of selecting 5-30 locations, I will select only museums which I have visited.
NYC_museums <- st_read(
"C:\\Users\\Mary Geschwindt\\Documents\\GitHub1\\mgeschwindt-vis\\NYC_Museums.KML") %>%
filter(Name %in% c("American Museum of Natural History", "Cloisters", "New Museum of Contemporary Art", "Skyscraper Museum", "Whitney Museum of American Art", "Cooper-Hewitt, National Design Museum", "Fraunces Tavern Museum", "Frick Collection", "Metropolitan Museum of Art (MET)", "Morgan Library and Museum", "Museum of Modern Art (MoMA)", "Museum of the City of New York", "Solomon R. Guggenheim Museum", "Studio Museum in Harlem"))
opq(bbox = 'New York NY USA') %>%
add_osm_feature(key = 'highway') %>%
osmdata_xml(file = 'OTP/graphs/default/newyork_streets.osm')
NY_state_plane <- "+proj=tmerc +lat_0=38.83333333333334 +lon_0=-74.5 +k=0.9999 +x_0=150000 +y_0=0 +ellps=GRS80 +units=m +no_defs"
nyc_street_features <- opq(bbox = 'New York NY USA') %>%
add_osm_feature(key = 'highway') %>%
osmdata_sf()
nyc_streets <- nyc_street_features$osm_lines %>%
st_transform(crs = NY_state_plane)
I’ll create a test map to make sure the NYC street geometries have been loaded correctly:
ggplot(nyc_streets) +
geom_sf() +
theme_map()
path_otp <- otp_dl_jar("OTP")
path_data <- file.path(getwd(), "OTP")
path_otp <- paste(path_data, "otp.jar",sep = "/")
otp_build_graph(otp = path_otp, dir = path_data, memory = 1024)
otp_setup(otp = path_otp, dir = path_data, memory =1024)
otpcon <- otp_connect()
Now that I have my data, geography, and OTP setup, I will create an isochrone depicting the 10 minute walkshed and bikeshed around each NYC museum I selected. I’ll create several isochrones to test out various aesthetics, but each will depict the same walksheds and bikesheds.
I want to give credit to my classmate Cristina Davila Gonzalez and her work on Assignment 1 for helping me to learn how to use different color palettes in my figures, which I have learned how to use for this assignment.
iso_10min_walk <-
otp_isochrone(otpcon = otpcon, fromPlace = NYC_museums,
mode = "WALK", cutoffSec = 600) %>%
st_transform(crs = NY_state_plane) %>%
mutate(mode = "walk")
iso_10min_bike <-
otp_isochrone(otpcon = otpcon, fromPlace = NYC_museums,
mode = "BICYCLE", cutoffSec = 600) %>%
st_transform(crs = NY_state_plane) %>%
mutate(mode = "bicycle")
iso_all_modes <- rbind(iso_10min_bike, iso_10min_walk)
otp_stop()
right_side <- st_bbox(iso_all_modes)$xmax
left_side <- st_bbox(iso_all_modes)$xmin
top_side <- st_bbox(iso_all_modes)$ymax
bottom_side <- st_bbox(iso_all_modes)$ymin
ggplot(iso_all_modes) +
annotation_map_tile(zoomin = 0, type = "cartolight", progress = "none") +
geom_sf(aes(fill = mode), alpha = 0.5) +
geom_sf(data = NYC_museums, aes()) +
coord_sf(xlim = c(left_side, right_side),
ylim = c(bottom_side, top_side), expand = FALSE) +
scale_fill_manual(name = "Area that is reachable within 10 minutes",
values = wes_palette("FantasticFox1", n=2),
labels = c("By bike", "By foot")) +
theme_map() +
theme(legend.background = element_rect(fill = alpha("white", 0.5), color = "black"),
legend.position = c(0.08, 0.75),
legend.key.size = unit(0.3, "cm")) +
labs(caption = "Basemap Copyright OpenStreetMap contributors")
## Loading required namespace: raster
ggplot(iso_all_modes) +
annotation_map_tile(zoomin = 0, type = "stamenbw", progress = "none") +
geom_sf(aes(fill = mode), alpha = 0.5) +
geom_sf(data = NYC_museums) +
coord_sf(xlim = c(left_side, right_side),
ylim = c(bottom_side, top_side), expand = FALSE) +
scale_fill_manual(name = "Area that is reachable within 10 minutes",
values = wes_palette("Moonrise3", n=2),
labels = c("By bike", "By foot")) +
theme_map() +
theme(legend.background = element_rect(fill = alpha("white", 0.9), color = "black"),
legend.position = c(0.08, 0.75),
legend.key.size = unit(0.3, "cm")) +
labs(caption = "Basemap Copyright OpenStreetMap contributors")
ggplot(iso_all_modes) +
geom_sf(data = nyc_streets, color = "gray") +
geom_sf(aes(fill = mode), alpha = 0.5) +
geom_sf(data = NYC_museums) +
coord_sf(xlim = c(left_side, right_side),
ylim = c(bottom_side, top_side), expand = FALSE) +
scale_fill_manual(name = "Area that is reachable within 10 minutes",
values = wes_palette("GrandBudapest2", n = 2),
labels = c("By bike", "By foot")) +
theme_map() +
theme(legend.background = element_rect(fill = alpha("white", 0.9), color = "black"),
legend.position = c(0.08, 0.75),
legend.key.size = unit(0.3, "cm")) +
labs(caption = "Basemap Copyright OpenStreetMap contributors")
I will create a scatterplot to compare the isochrones showing the 10 minute walkshed vs. bikeshed for the selected museums.
iso_areas <- iso_all_modes %>%
mutate(area = st_area(iso_all_modes)) %>%
st_set_geometry(NULL) %>%
pivot_wider(names_from = mode, values_from = area)
ggplot(iso_areas,
aes(x = as.numeric(walk), y = as.numeric(bicycle))) +
geom_point() +
stat_smooth(method = "lm") +
scale_x_continuous(name =
"Area within a ten-minute walking distance\nof a museum\n(square km)",
breaks = breaks <- seq(10000, 8000000, by = 100000),
labels = breaks / 1000000) +
scale_y_continuous(name =
"Area within a ten-minute biking distance\nof a museum\n(square km)",
breaks = breaks <- seq(0, 8000000, by = 1000000),
labels = breaks / 1000000) +
theme_bw()
I want to know how much larger of an area around a museum is covered by a 10 minute bike ride as compared to a 10 minute walk. I will create a bar chart which compares the area covered by a 10 minute bike ride and a 10 minute walk for each museum. My x-axis will be the area, and my y-axis will be the museums. In order to show this comparison between 2 modes of transportation on the same bar chart, I’ll have to create a new dataframe.
I will give credit to my classmate Julia Meinhardt for helping me to resolve an issue in my code with showing the colors in the bar chart.
iso_areas_2 <- data.frame(mode = rep(c("Bicycle", "Walk"), each = 14),
museum =rep(c("American Museum of Natural History",
"Cloisters",
"New Museum of Contemporary Art",
"Skyscraper Museum",
"Whitney Museum of American Art",
"Cooper-Hewitt, National Design Museum",
"Fraunces Tavern Museum",
"Frick Collection",
"Metropolitan Museum of Art (MET)",
"Morgan Library and Museum",
"Museum of Modern Art (MoMA)",
"Museum of the City of New York",
"Solomon R. Guggenheim Museum",
"Studio Museum in Harlem")),
area = c(5776098, 3156259, 6032629, 3267062, 6203797, 4772197, 6322727, 5462318, 6303734, 7880639, 1846491, 6549625, 6495606, 5888841, 616861.7, 401077.9, 620392.3, 608556.3, 657121.6, 436404.3, 605569.3, 468155.2, 741954.8, 785867.6, 327229.0, 668817.6, 753486.9, 700258.6))
ggplot(iso_areas_2,
aes(x = as.numeric(area), y = museum, fill = mode)) +
geom_bar(stat = "identity", width = 0.5, position = position_dodge2()) +
scale_x_continuous(name = "Area Covered (km^2)",
breaks = breaks <- seq(10000, 8000000, by = 1000000),
labels = breaks / 1000000) +
scale_y_discrete(name = "Museums",
labels = c("American Museum of Natural History",
"Cloisters",
"New Museum of Contemporary Art",
"Skyscraper Museum",
"Whitney Museum of American Art",
"Cooper-Hewitt, National Design Museum",
"Fraunces Tavern Museum",
"Frick Collection",
"Metropolitan Museum of Art (MET)",
"Morgan Library and Museum",
"Museum of Modern Art (MoMA)",
"Museum of the City of New York",
"Solomon R. Guggenheim Museum",
"Studio Museum in Harlem")) +
scale_fill_manual(name = "Mode",
values = wes_palette("GrandBudapest2", n = 2, type = c("discrete")),
labels = c("Bicycle",
"Walk")) +
labs(title = "Comparing Area Covered by 10-minute Walks\nand Bikerides Around Each Museum") +
theme_minimal()
I will create a stacked area chart showing area coverage for walksheds and bikesheds for each museum.
NOTE: I was unable to get the areas to plot, but this is something which I would like to continue to work through following this assignment’s submission, since this is an extra figure I’m trying to create.
ggplot(iso_areas_2, aes(x = museum, y = as.numeric(area), fill = mode)) +
geom_area() +
scale_x_discrete(name = "Museums",
labels = c("American\nMuseum of\nNatural\nHistory",
"Cloisters",
"New\nMuseum",
"Skyscraper\nMuseum",
"Whitney\nMuseum",
"Cooper-Hewitt",
"Fraunces\nTavern\nMuseum",
"Frick\nCollection",
"Metropolitan\nMuseum\nof Art",
"Morgan\nLibrary\nand Museum",
"Museum of\nModern Art\n(MoMA)",
"Museum\nof the\nCity of\nNew York",
"Guggenheim\nMuseum",
"Studio\nMuseum\nin Harlem")) +
scale_y_continuous(name = "Area Covered (km^2)",
breaks = breaks <- seq(10000, 8000000, by = 1000000),
labels = breaks / 1000000) +
scale_fill_manual(name = "Mode",
values = wes_palette("Darjeeling1", n = 2, type = c("discrete"))) +
labs(title = "Comparing Area Covered by 10-minute Walks\nand Bikerides Around Each Museum") +
theme_minimal()
otp_stop()
## Warning in system("Taskkill /IM java.exe /F", intern = TRUE): running command
## 'Taskkill /IM java.exe /F' had status 128
All of the museums selected in this assignment are located on the island of Manhattan, which has a width of about 2.3 miles at its widest point. From visualizing the 10 minute walksheds and bikesheds around the selected museums, it was interesting to see that often, the bikesheds span the width of the island. The walksheds are considerably smaller compared to the area that is covered under the bikesheds.
I may assume that the reason for bikes being able to cover a much larger area is related to speed. I would imagine that the grid pattern of Manhattan means that both pedestrians and bicyclists have few turns to make before being able to travel along a straight line to their destinations. However, a bicyclist is able to travel much faster than a pedestrian. One piece of information which would be interesting to look at is where the bike lanes are, and understand how bike lane locations can influence bicycle travel time. Because many streets in New York are one-way, this would affect the choices a bicyclist would have in his or her route. On the other hand, a pedestrian is not constrained to walk any certain direction on the sidewalk, and therefore has many more options in where to turn or continue walking straight.
My assumption that speed is the reason for why bikes can cover a much larger area in the 10 minute bikeshed must be further studied by reviewing real-world conditions and pedestrian and bicyclist behaviors. As someone with experience as both a pedestrian and a bicyclist in New York, I know that on-the-ground conditions can influence decisions on where to walk or bike. For example, there may be some roads which provide a more direct route by bike which would take less time, but these routes may not have sufficient protected bike lanes. The lack of sufficient bicycle infrastructure may cause me to opt for a longer route which has better safety conditions.